package com.changfen.service;

import io.seata.rm.tcc.api.BusinessActionContext;
import io.seata.rm.tcc.api.BusinessActionContextParameter;
import io.seata.rm.tcc.api.LocalTCC;
import io.seata.rm.tcc.api.TwoPhaseBusinessAction;

/**
 * @author changfeng.chen@things-matrix.com
 * @date 2022/9/27 21:44
 **/
@LocalTCC
public interface TccAccountService {
    /**
     * 一阶段的try方法，用户资源的预留，注解@BusinessActionContextParameter 用户设置参数到businessActionContext
     * @return
     */
    @TwoPhaseBusinessAction(name = "addOrderTcc",commitMethod = "commit",rollbackMethod = "rollback")
    boolean tryCreate(
            BusinessActionContext businessActionContext,
            @BusinessActionContextParameter(paramName = "userId") Long userId);


    boolean commit(BusinessActionContext businessActionContext);


    boolean rollback(BusinessActionContext businessActionContext);


}
